1. Field of the Invention
The present invention relates to the technical field of image compression/decompression and, more particularly, to a method and apparatus of fixed bit-rate image compression/decompression based on 2×2 image unit.
2. Description of Related Art
Typically, the lossless image compression can be divided into, for example, run length coding, Huffman coding, Lempel-Ziv-Weich coding, arithmetic coding, differential coding, and lossless JPEG coding. The run length coding uses two bytes to indicate a series of data with the same value, wherein the first byte indicates the length of the series of data and the second byte records the value of the data. For example, the run length coding is performed on data “555555AA” to generate “652A” for indicating that there are six “5s” and two “As”, and in this case four bytes are saved. However, the run length coding has to calculate the repetition data rate, and when the data has a low repetition rate, the compression rate becomes low. The Huffman coding is based on the presence probability to perform a binary tree coding on input data. The symbols of the input data with a high presence probability are given with a short code, and the symbols with a low presence probability are given with a long code. Thus, the amount of data used in average can be reduced. However, similar to the run length coding, the Huffman coding has to calculate the presence probability of the input data.
The Lempel-Ziv-Weich coding uses a present string as an index to compare with a lookup table, and establishes an indexing scheme as a data compression stream. However, the Lempel-Ziv-Weich coding has to use a large memory space for temporarily storing the established tables.
The arithmetic coding is characterized in using a real number to represent a compressed string, instead of using a symbol to represent one bit. Such a way needs to first read an original string once in order to calculate the presence probability of each different codeword, divide a range of real numbers from zero to one into a table of original coding intervals, sequentially read the characters of the original string, and further divide the original coding interval occupied by each read character based on the table of original coding intervals until the last character is read and a last interval is obtained. A real number of the last interval is selected to represent the compressed file of the original string. The code obtained by the arithmetic coding requires only a space for storing one floating number, but not a large of storage space as cited in the Huffman coding. However, the arithmetic coding has the disadvantage of very complicated computation required for the presence probability and algorithm of the input data.
The differential coding is based on a difference between an estimate and an actual value for compression, but has a low bit rate as it is used alone. The lossless JPEG coding is based on a discrete cosine transform and predicted error values.
In the aforementioned image compressions, the bit rates are not fixed and thus more computation resources are required in decompression for accurately obtaining the data length. In addition, an embedded system or a handheld device has limited computation capability and memory capacity. Therefore, the cited image compressions are not satisfactory for the embedded system or the handheld device. Accordingly, it is desirable to provide an improved image compression and decompression for an embedded system or a handheld device to mitigate and/or obviate the aforementioned problems.